import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useCounterStore = defineStore(
  'counter',
  () => {
    const count = ref(0)
    const msg = ref('hello')
    const doubleCount = computed(() => count.value * 2)
    function increment() {
      count.value++
    }

    function addMsg() {
      msg.value += '~'
    }

    return { count, doubleCount, increment, addMsg, msg }
  },
  // { unistorage: true } // 缓存全部
  {
    unistorage: {
      key: 'xxx',
      paths: ['count'],
    },
  }
)